﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for user_group
/// </summary>
public class user_groupDAL
{
    DataAccess da = new DataAccess();
	public user_groupDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    //public DataTable getAllUser_group()
    //{

    //}
    public int EditUserGroup(int user_group_id, string name, string permission)
    {
        SqlParameter[] param = new SqlParameter[3];
        param[0] = da.AddParameter("user_group_id", user_group_id, SqlDbType.Int, null);
        param[1] = da.AddParameter("name", name, SqlDbType.NVarChar, 30);
        param[2] = da.AddParameter("permission", permission, SqlDbType.Text, null);
        return da.executeUpdate("EDIT_USER_GROUP", param);
    }
    public int DeleteUserGroup(int user_group_id)
    {
        SqlParameter[] param = new SqlParameter[1];
        param[0] = da.AddParameter("user_group_id", user_group_id, SqlDbType.Int, null);
        return da.executeUpdate("EDIT_USER_GROUP", param);
    }

    public DataTable getAllUserGroup()
    {
        return da.executeSelect("GET_USERGROUP");   
    }

    public DataTable getUserGroupByID(int user_group_id)
    {
        SqlParameter[] param = new SqlParameter[1];
        param[0] = da.AddParameter("user_group_id", user_group_id, SqlDbType.Int, null);
        return da.executeSelect("GET_USERGROUP", param);
    }

}